<?php

namespace app\common\model\api;

use think\Model;

class User extends Model
{

    protected $table = 'api_user';

    public function fundByUserName($username)
    {
        return $this->where('username', $username)->find();
    }

    public function fundByUserNameWithStatus($username)
    {
        return $this->where('username', $username)->where('status', 1)->find();
    }

    public function updateLoginInfo($data)
    {
        $result = $this->fundByUserNameWithStatus($data['username']);
        return $result->allowField(['last_login_token'])->save($data);
    }
}
